package tutorial.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import Util.StdOut;

public class ScanSum {

    public static void main(String[] args) {
        Scanner scanner = null;
        double sum = 0;
        
        try {
            scanner = new Scanner(new File("src/tutorial/io/usnumbers.txt"));
            while (scanner.hasNext()) {
                if (scanner.hasNextDouble()) {
                    sum += scanner.nextDouble();
                } else {
                    scanner.next();
                }
            }
            StdOut.println("Sum: " + sum);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            scanner.close();
        }
    }
}
